package yhp.dao.impl;

import yhp.bean.Users;
import yhp.dao.UserDao;
import yhp.util.DruidUtil;

import javax.xml.registry.infomodel.User;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
//接口名+Impl=当前类名
//Dao实现类
public class UserDaoImpl extends DruidUtil implements UserDao {
    @Override
    public List<Users> getall() {
        /*List list = new ArrayList();
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try {
            connection = getConnection();
            preparedStatement = connection.prepareStatement("select  * from users");
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                Users users = new Users();
                users.setId(resultSet.getInt("id"));
                users.setUsername(resultSet.getNString("username"));
                users.setPassword(resultSet.getInt("password"));
                users.setAccount(resultSet.getInt("account"));
                list.add(users);
            }
        }catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally {
            close(connection,preparedStatement,resultSet);
        }
        return null;*/
        ResultSet query = DruidUtil.query("select * from users",List.of(username));
        if (query.next()) {
            String username = query.getString("username");
            String password = query.getString("password");
        }
        }
    }

